import java.util.Scanner;
import java.util.concurrent.*;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/4/19 15:23
 *  字符串计数
 *  最长公共子序列 DP
 */
public class Day39 {
    //---------------------------------------------------
    public static void main(String[] args) {
        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(3,10,1000, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<>());
        ScheduledExecutorService executors = Executors.newScheduledThreadPool(2);
        executors.schedule(()->{
            System.out.println("/");
        },21,TimeUnit.SECONDS);
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String str1 = scanner.next();
            String str2 = scanner.next();
            char[] ch1 = str1.toCharArray();
            char[] ch2 = str2.toCharArray();
            int[][] dp = new int[ch1.length+1][ch2.length+1];

            for (int i = 1; i <= ch1.length; i++) {
                for (int j = 1; j <= ch2.length; j++) {
                    if (ch1[i-1]==ch2[j-1]){
                        dp[i][j]=dp[i-1][j-1]+1;
                    }else {
                        dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
                    }
                }
            }
            System.out.println(dp[ch1.length][ch2.length]);
        }
    }
    //---------------------------------------------------
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            //一组测试用例!
            StringBuffer str1 = new StringBuffer(sc.next());
            StringBuffer str2 = new StringBuffer(sc.next());
            int len1 = sc.nextInt();
            int len2 = sc.nextInt();
            //将str1 和 str2 补位到len2
            for(int i = str1.length();i<len2;i++){//str1 补 a
                str1.append('a');
            }
            for(int i = str2.length();i<len2;i++){//str2 补'z'+1
                str2.append('z'+1);
            }
            //用于保存字符串相减后每位的差值!
            //便于计算每个长度的个数
            int[] array = new int[len2];
            for(int i = 0;i<len2;i++){
                array[i] = str2.charAt(i) - str1.charAt(i);
            }
            //进行求和!
            int result = 0;
            for(int i = len1;i<=len2;i++){//长度[len1,len2]
                for(int j = 0;j<i;j++){ //计算每一个长度的个数!
                    //进行多少位的相减!
                    result += array[j]*Math.pow(26,i-j-1);// 1位 26^0 2位 26^1 ....
                }
            }
            System.out.println((result-1)%1000007); //减去str2 重复计算!
        }
    }
}
